package Eyjafjalla.card.attack;

import Eyjafjalla.action.EyjafjallaAttackAction;
import Eyjafjalla.action.IncreaseCardAction;
import Eyjafjalla.action.SilentAction;
import Eyjafjalla.card.AbstractEyjafjallaCard;
import Eyjafjalla.effect.ShowCardAndAttachEffect;
import Eyjafjalla.helper.EyjafjallaHelper;
import Eyjafjalla.patch.CloudFixPatch;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.VulnerablePower;

public class SilentSound_Eyjafjalla extends AbstractEyjafjallaCard {
    public static final String ID = "SilentSound_Eyjafjalla";
    private static final CardStrings cardStrings;

    public SilentSound_Eyjafjalla(){
        super(ID, cardStrings.NAME,2,cardStrings.DESCRIPTION,CardType.ATTACK,CardRarity.UNCOMMON,CardTarget.ENEMY);
        this.baseDamage = 12;
        this.damage =12;
        this.baseMagicNumber = 1;
        this.magicNumber = 1;
        setFireDescription(cardStrings.EXTENDED_DESCRIPTION[0]);
    }

    @Override
    public AbstractCard makeCopy() {
        return new SilentSound_Eyjafjalla();
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new EyjafjallaAttackAction());
        //注：1是清空记录，作为首次攻击；2是结算格挡，作为末次攻击；3是当没有多段攻击（即m=1）时，同时清空并结算格挡
        addToBot(new SilentAction(m,new DamageInfo(p,damage,damageTypeForTurn),(this.magicNumber==1&&isFire())?3:1));
        for(int i =0;i<this.magicNumber-1;i++){
            addToBot(new SilentAction(m,new DamageInfo(p,damage,damageTypeForTurn),(i==this.magicNumber-2&&isFire())?2:0));
        }
    }

    @Override
    public void atTurnStart() {
        if(!CloudFixPatch.canSetRoundEnd)
            return;
        for(AbstractCard c:AbstractDungeon.actionManager.cardsPlayedThisTurn){
            if(c.type==CardType.ATTACK)
                return;
        }
        this.baseMagicNumber++;
        this.magicNumber = baseMagicNumber;
        AbstractDungeon.topLevelEffectsQueue.add(new ShowCardAndAttachEffect(this.makeStatEquivalentCopy(),AbstractDungeon.player,true));
    }


    @Override
    public void upgrade() {
        if(!this.upgraded){
            upgradeName();
            upgradeDamage(4);
        }
    }

    static {
        cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    }
}


